/*
 * Copyright (c) 2020-2099 the original author or authors. All rights reserve.
 */
package org.tianyun.cloud.config.refresh.smart.annotation;

import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.annotation.AliasFor;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Scope的一个扩展，Environment配置变动刷新，对应配置变动后销毁指定Bean，根据prefix匹配
 *
 * @auther ebert_chan
 */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Scope(org.tianyun.cloud.config.refresh.smart.SmartScope.SCOPE_NAME)
@Documented
public @interface SmartScope {

    /**
     * The prefix of the properties that are valid to bind to this object. Synonym for {@link #prefix()}. A valid prefix is defined by one or more
     * words separated with dots (e.g. {@code "acme.system.feature"}).
     *
     * @return the prefix of the properties to bind
     */
    @AliasFor("prefix")
    String value() default "";

    /**
     * The prefix of the properties that are valid to bind to this object. Synonym for {@link #value()}. A valid prefix is defined by one or more
     * words separated with dots (e.g. {@code "acme.system.feature"}).
     *
     * @return the prefix of the properties to bind
     */
    @AliasFor("value")
    String prefix() default "";

    /**
     * @return proxy mode
     * @see Scope#proxyMode()
     */
    ScopedProxyMode proxyMode() default ScopedProxyMode.TARGET_CLASS;

}
